package com.ithema.reggie.mapper;

import com.ithema.reggie.entity.Category;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface CategoryMapper {
    //查询所有的类别
    @Select("select * from category order by sort")
    List<Category> findAll();

    @Insert("insert into category values(null,#{type},#{name},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void save(Category category);

    @Update("update category set name=#{name},sort=#{sort},update_time=#{updateTime},update_user=#{updateUser} where id = #{id}")
    void update(Category category);

    @Delete("delete from category where id = #{id}")
    void deleteById(Long id);

    List<Category> findAllByType(Integer t0ype);
}
